package main

import (
	"fmt"
	"time"
)

type Student struct {
	Name    string
	Number  int
	Subject []string
	Scores  []int
}

type Class struct {
	Name     string
	Number   int
	Students []Student
}

var cl1 = Class{
	Name:   "grade1",
	Number: 1,
	Students: []Student{
		{
			Name:    "zhangsan",
			Number:  101,
			Subject: []string{"chn", "math", "eng"},
			Scores:  []int{99, 98, 95},
		},
		{
			Name:    "lisi",
			Number:  102,
			Subject: []string{"chn", "math", "eng"},
			Scores:  []int{100, 99, 99},
		},
		{
			Name:    "wangwu",
			Number:  103,
			Subject: []string{"chn", "math", "eng"},
			Scores:  []int{87, 89, 93},
		},
	},
}

var cl2 = Class{
	Name:   "grade1",
	Number: 2,
	Students: []Student{
		{
			Name:    "zhaoliu",
			Number:  104,
			Subject: []string{"chn", "math", "eng"},
			Scores:  []int{98, 99, 95},
		},
		{
			Name:    "songbao",
			Number:  105,
			Subject: []string{"chn", "math", "eng"},
			Scores:  []int{96, 94, 83},
		},
	},
}

func GertAvgScore(cl *Class) {
	Name := cl.Name
	Number := cl.Number
	var chnSum, mathSum, engSum int
	studentsCount := len(cl.Students)
	for _, line := range cl.Students {
		chnSum += line.Scores[0]
		mathSum += line.Scores[1]
		engSum += line.Scores[2]
	}
	chnAvg := chnSum / studentsCount
	mathAvg := mathSum / studentsCount
	engAvg := engSum / studentsCount
	fmt.Printf("Avg of %v %d %s : %d\n", Name, Number, "chn", chnAvg)
	fmt.Printf("Avg of %v %d %s : %d\n", Name, Number, "math", mathAvg)
	fmt.Printf("Avg of %v %d %s : %d\n", Name, Number, "eng", engAvg)
}

func main() {
	GertAvgScore(&cl1)
	GertAvgScore(&cl2)
	fmt.Println(time.Now())
}
